﻿//-------------------------------------------------------------------------------------
// All Rights Reserved , Copyright (C) 2011 , Hairihan TECH, Ltd.
//-------------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Data;
using System.Reflection;

namespace DotNet.Service
{
    using DotNet.Business;
    using DotNet.DbUtilities;
    using DotNet.IService;
    using DotNet.Model;
    using DotNet.Utilities;

    /// <summary>
    /// RoleService
    /// 角色服务
    ///
    /// 修改纪录
    ///
    ///     2010.03.12 版本：1.5 JiRiGaLa 程序注释整理、函数整理、函数顺序等。
    ///     2008.04.09 版本：1.4 JiRiGaLa 重新整理主键。
    ///     2007.06.11 版本：1.3 JiRiGaLa 加入调试信息#if (DEBUG)。
    ///     2007.06.04 版本：1.2 JiRiGaLa 加入WebService。
    ///     2007.05.29 版本：1.1 JiRiGaLa 排版，修改，完善。
    ///		2007.05.11 版本：1.0 JiRiGaLa 窗体与数据库连接的分离。
    ///
    /// 版本：1.3
    ///
    /// <author>
    ///		<name>JiRiGaLa</name>
    ///		<date>2007.06.11</date>
    /// </author>
    /// </summary>
    public class RoleService : System.MarshalByRefObject, IRoleService
    {
        /// <summary>
        /// 用户中心数据库连接
        /// </summary>
        private readonly string UserCenterDbConnection = BaseSystemInfo.UserCenterDbConnection;

        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="userInfo">操作员</param>
        /// <param name="roleEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状态信息</param>
        /// <returns>主键</returns>
        public string Add(BaseUserInfo userInfo, BaseRoleEntity roleEntity, out string statusCode, out string statusMessage)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif
            string returnValue = string.Empty;

            IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);
                dbHelper.BeginTransaction();
                BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo);
                returnValue = roleManager.Add(roleEntity, out statusCode);
                statusMessage = roleManager.GetStateMessage(statusCode);
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
                dbHelper.CommitTransaction();
            }
            catch (Exception ex)
            {
                dbHelper.RollbackTransaction();
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif
            return returnValue;
        }

        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="userInfo">操作员</param>
        /// <returns>数据表</returns>
        public DataTable GetDT(BaseUserInfo userInfo)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif
            DataTable dataTable = new DataTable(BaseRoleTable.TableName);

            IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);

                // 获得角色列表
                BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo);
                dataTable = roleManager.GetDT(BaseRoleTable.FieldDeletionStateCode, 0, BaseRoleTable.FieldSortCode);
                dataTable.TableName = BaseRoleTable.TableName;
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
            }
            catch (Exception ex)
            {
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif
            return dataTable;
        }

        /// <summary>
        /// 按组织机构获取角色
        /// </summary>
        /// <param name="userInfo">操作员</param>
        /// <param name="systemId">系统主键</param>
        /// <returns>数据表</returns>
        public DataTable GetDTByOrganize(BaseUserInfo userInfo, string systemId)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif
            DataTable dataTable = new DataTable(BaseRoleTable.TableName);

            IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);

                // 获得角色列表
                BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo);
                dataTable = roleManager.GetDTBySystem(systemId);
                dataTable.TableName = BaseRoleTable.TableName;
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
            }
            catch (Exception ex)
            {
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif
            return dataTable;
        }

        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="userInfo">操作员</param>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        public BaseRoleEntity GetEntity(BaseUserInfo userInfo, string id)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif
            BaseRoleEntity roleEntity = null;

            IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);
                BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo);
                roleEntity = roleManager.GetEntity(int.Parse(id));
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
            }
            catch (Exception ex)
            {
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif
            return roleEntity;
        }

        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="userInfo">操作员</param>
        /// <param name="roleEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状态信息</param>
        /// <returns>影响行数</returns>
        public int Update(BaseUserInfo userInfo, BaseRoleEntity roleEntity, out string statusCode, out string statusMessage)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif
            int returnValue = 0;

            IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);
                dbHelper.BeginTransaction();
                BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo);
                returnValue = roleManager.Update(roleEntity, out statusCode);
                statusMessage = roleManager.GetStateMessage(statusCode);
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
                dbHelper.CommitTransaction();
            }
            catch (Exception ex)
            {
                dbHelper.RollbackTransaction();
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif
            return returnValue;
        }

        /// <summary>
        /// 获取角色列表
        /// </summary>
        /// <param name="userInfo">操作员</param>
        /// <param name="ids">角色主键</param>
        /// <returns>数据表</returns>
        public DataTable GetDTByIds(BaseUserInfo userInfo, string[] ids)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif
            DataTable dataTable = new DataTable(BaseRoleTable.TableName);

            IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);
                BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo);
                dataTable = roleManager.GetDT(BaseRoleTable.FieldId, ids, BaseRoleTable.FieldSortCode);
                dataTable.TableName = BaseRoleTable.TableName;
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
            }
            catch (Exception ex)
            {
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif
            return dataTable;
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="userInfo">操作员</param>
        /// <param name="organizeId">组织机构主键</param>
        /// <param name="search">查询字符串</param>
        /// <returns>数据表</returns>
        public DataTable Search(BaseUserInfo userInfo, string organizeId, string searchValue)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif
            DataTable dataTable = new DataTable();

            IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);

                // 获得角色列表
                BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo);
                dataTable = roleManager.Search(organizeId, searchValue);
                dataTable.TableName = BaseRoleTable.TableName;
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
            }
            catch (Exception ex)
            {
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif
            return dataTable;
        }

        /// <summary>
        /// 批量保存
        /// </summary>
        /// <param name="userInfo">操作员</param>
        /// <param name="roleEntites">角色列表</param>
        /// <returns>影响行数</returns>
        public int BatchSave(BaseUserInfo userInfo, List<BaseRoleEntity> roleEntites)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif

            int returnValue = 0;
            IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);
                dbHelper.BeginTransaction();
                BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo);
                returnValue = roleManager.BatchSave(roleEntites);
                // dataTable = Role.GetDTByOrganize(organizeId);
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
                dbHelper.CommitTransaction();
            }
            catch (Exception ex)
            {
                dbHelper.RollbackTransaction();
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif
            return returnValue;
        }

        /// <summary>
        /// 移动数据
        /// </summary>
        /// <param name="userInfo">操作员</param>
        /// <param name="id">主键</param>
        /// <param name="targetId">目标主键</param>
        /// <returns>影响行数</returns>
        public int MoveTo(BaseUserInfo userInfo, string id, string targetId)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif
            int returnValue = 0;

            IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);
                BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo);
                returnValue = roleManager.MoveTo(id, targetId);
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
            }
            catch (Exception ex)
            {
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif
            return returnValue;
        }

        /// <summary>
        /// 批量移动数据
        /// </summary>
        /// <param name="userInfo">操作员</param>
        /// <param name="ids">主键数组</param>
        /// <param name="targetId">目标主键</param>
        /// <returns>影响行数</returns>
        public int BatchMoveTo(BaseUserInfo userInfo, string[] ids, string targetId)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif
            int returnValue = 0;

            IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);
                BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo);
                returnValue = roleManager.BatchMoveTo(ids, targetId);
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
            }
            catch (Exception ex)
            {
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif
            return returnValue;
        }

        /// <summary>
        /// 排序顺序
        /// </summary>
        /// <param name="userInfo">操作员</param>
        /// <param name="organizeId">组织机构主键</param>
        /// <returns>影响行数</returns>
        public int ResetSortCode(BaseUserInfo userInfo, string organizeId)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif
            int returnValue = 0;

            IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);
                BaseRoleManager roleManager = new BaseRoleManager(dbHelper);
                returnValue = roleManager.ResetSortCode(organizeId);
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
            }
            catch (Exception ex)
            {
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif

            return returnValue;
        }

        /// <summary>
        /// 获得角色中的用户主键
        /// </summary>
        /// <param name="userInfo">操作员</param>
        /// <param name="roleId">角色主键</param>
        /// <returns>用户主键</returns>
        public string[] GetRoleUserIds(BaseUserInfo userInfo, string roleId)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif

            string[] returnValue = null;
            IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);
                BaseUserRoleManager userRoleManager = new BaseUserRoleManager(dbHelper, userInfo);
                returnValue = userRoleManager.GetUserIds(roleId);
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
            }
            catch (Exception ex)
            {
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif
            return returnValue;
        }

        /// <summary>
        /// 用户添加到角色
        /// </summary>
        /// <param name="userInfo">操作员</param>
        /// <param name="roleId">角色主键</param>
        /// <param name="addUserIds">用户主键</param>
        /// <returns>影响行数</returns>
        public int AddUserToRole(BaseUserInfo userInfo, string roleId, string[] addUserIds)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif

            int returnValue = 0;
            IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);
                BaseUserRoleManager userRoleManager = new BaseUserRoleManager(dbHelper, userInfo);

                // 小心异常，检查一下参数的有效性
                if (addUserIds != null)
                {
                    returnValue += userRoleManager.AddToRole(addUserIds, roleId);
                }
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
            }
            catch (Exception ex)
            {
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif
            return returnValue;
        }

        /// <summary>
        /// 将用户从角色中移除
        /// </summary>
        /// <param name="userInfo">操作员</param>
        /// <param name="roleId">角色主键</param>
        /// <param name="userIds">用户主键</param>
        /// <returns>影响行数</returns>
        public int RemoveUserFromRole(BaseUserInfo userInfo, string roleId, string[] userIds)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif

            int returnValue = 0;
            IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);
                dbHelper.BeginTransaction();
                BaseUserRoleManager userRoleManager = new BaseUserRoleManager(dbHelper, userInfo);
                if (userIds != null)
                {
                    returnValue += userRoleManager.RemoveFormRole(userIds, roleId);
                }
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
                dbHelper.CommitTransaction();
            }
            catch (Exception ex)
            {
                dbHelper.RollbackTransaction();
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif
            return returnValue;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="userInfo">操作员</param>
        /// <param name="id">主键</param>
        /// <returns>数据表</returns>
        public int Delete(BaseUserInfo userInfo, string id)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif
            int returnValue = 0;

            IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);
                BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo);
                returnValue = roleManager.Delete(id);
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
            }
            catch (Exception ex)
            {
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif
            return returnValue;
        }

        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="userInfo">操作员</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int BatchDelete(BaseUserInfo userInfo, string[] ids)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif
            int returnValue = 0;

            IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);

                // 开始数据库事务
                dbHelper.BeginTransaction();
                BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo);
                returnValue = roleManager.BatchDelete(ids);
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());

                // 递交数据库事务
                dbHelper.CommitTransaction();
            }
            catch (Exception ex)
            {
                // 撤销数据库事务
                dbHelper.RollbackTransaction();
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif
            return returnValue;
        }

        /// <summary>
        /// 批量做删除标志
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int SetDeleted(BaseUserInfo userInfo, string[] ids)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif
            int returnValue = 0;

            IDbHelper dbHelper = DbHelperFactory.GetHelper();
            try
            {
                dbHelper.Open(UserCenterDbConnection);
                BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo);
                returnValue = roleManager.SetDeleted(ids);
                BaseLogManager.Instance.Add(dbHelper, userInfo, MethodBase.GetCurrentMethod());
            }
            catch (Exception ex)
            {
                BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                throw ex;
            }
            finally
            {
                dbHelper.Close();
            }

            // 写入调试信息
#if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
#endif
            return returnValue;
        }
    }
}